<template>
  <div class="video-toolbar">
    <div class="action">
      <van-tag class="btn fav" :class="{'btn-active': favChecked}" size="large" @click="setFav">
        <van-icon name="star" v-if="!favChecked"/>{{ favText }}
      </van-tag>
      <van-tag class="btn" size="large" @click="openShare">
        <van-icon name="share"/>分享
      </van-tag>
    </div>
    <share-sheet
      ref="share"
      :title="shareTitle"
      :pic="sharePic"
      :url="shareUrl"
    />
  </div>
</template>

<script>
import { Icon as VanIcon, Tag as VanTag } from 'vant'
import ShareSheet from '@/components/share-sheet/ShareSheet.vue'
export default {
  name: 'VideoToolbar',
  components: {
    VanIcon,
    VanTag,
    ShareSheet
  },
  props: {
    favChecked: {
      type: Boolean,
      default: false
    },
    shareTitle: {
      type: String
    },
    sharePic: {
      type: String
    }
  },
  data () {
    return {
      shareUrl: location.href
    }
  },
  computed: {
    favText () {
      return this.favChecked ? '已收藏' : '收藏'
    }
  },
  methods: {
    setFav () {
      this.$emit('fav-click')
    },
    openShare () {
      this.$refs.share.show()
    }
  }
}
</script>

<style lang="scss" scoped>
  .video-toolbar{
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    color: $color-text-secondary;
    font-size: 12px;
    .action{
      display: flex;
      align-items: center;
      .btn {
        margin-right: 5px;
        color: $color-text-secondary;
        background-color: #fff;
        font-size: 14px;
        &-active{
          color: $color-white;
          background-color: $theme-color;
        }
      }
    }
    .fa {
      margin-right: 5px;
      font-size: 12px;
    }
  }
</style>
